/*! 
 * Terrain (GameObject sample).
 *
 * \author Devis Rossini
 * \date 02 April 2012
 */
#ifndef PHXOGRETERRAIN_H_INCLUDE_GUARD
#define PHXOGRETERRAIN_H_INCLUDE_GUARD

#include "GameObject.h"

namespace GameObjects
{
	/*!
     * Terrain class.
     */
	class Terrain : public GameObject
	{
	public:

		// Shortcuts.
		typedef phx::HeightField		HeightField;
		typedef phx::HeightFieldData	HeightFieldData;

		/*!
         * Constructor.
		 *
		 * \note Creates the whole entity (physical and graphical).
         */
		Terrain(phx::Scene* iScene, Ogre::SceneManager* iSceneManager, Ogre::SceneNode* iParentNode,
			const Ogre::String& iHeightMapName, const float iHorizontalScaleFactor, const float iVerticalScaleFactor);

		/*!
         * Destructor.
         */
		virtual ~Terrain() { }

		/*!
         * Update the object.
         */
		virtual void Update(const float iDuration);

	protected:

		/*!
         * Create and initialize the physical entity associated to the object.
         */
		phx::CollisionPrimitive* CreatePhxEntity(phx::Scene* iScene,  const Ogre::String& iHeightMapName, 
			const float iHorizontalScaleFactor, const float iVerticalScaleFactor);

		/*!
         * Create the Ogre's entity associated to the object and insert it into the scenegraph.
         */
		Ogre::SceneNode* CreateOgreEntity(Ogre::SceneManager* iSceneManager, Ogre::SceneNode* iParentNode,
			const HeightField& iHeightField, const float iHorizontalScaleFactor, const float iVerticalScaleFactor);

		/*!
         * Initialize terrain with a random-calculated heightfield (only for our testbed).
         */
		void SetRandomHeights(phx::HeightField& oHeightField);
	};
}

#endif // PHXOGRETERRAIN_H_INCLUDE_GUARD